package com.sakura.demo.controller;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sakura.demo.bean.ScreeningItems;
import com.sakura.demo.common.lang.Result;
import com.sakura.demo.service.ScreeningItemsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Alan
 * @since 2024-07-18
 */
@RestController
@RequestMapping("/screeningItems")
public class ScreeningItemsController {
    @Resource
    HttpServletRequest request;
    @Autowired
    private ScreeningItemsService screeningItemsService;

    @RequestMapping("/getAllScreeningItems")
    public Result getAllScreeningItems(){
        //使用ServletRequestUtils工具类来处理默认情况（默认情况下不传页数、每页数量，此时应返回第一页数据，每页10个）
        Integer current = ServletRequestUtils.getIntParameter(request,"current",1);
        Integer size = ServletRequestUtils.getIntParameter(request,"size",10);
        Page<ScreeningItems> screeningItems = screeningItemsService.page(new Page<>(),new QueryWrapper<ScreeningItems>());
        return Result.success(screeningItems);
    }
}

